<?php
namespace app\admin\controller;
use think\Db;
use think\Controller;
use think\Session;
use think\Request;
class Login extends Controller 
{
	public function login() 
	{
		if (input("?post.sub"))
		{
		 
		 //return $this->fetch("main");	
		    $result =Db::table("jf_admin")
			          ->where('a_name','eq',$_POST['a_name'])			          
			          //->fetchSql(true)	         
			          ->find();		        
			 if($result)
			 {
			 	if($result['a_pwd']==$_POST['a_pwd'])
			 	{
			 	   Session::set('a_name',$result['a_name']);
			 	   Session::set('r_id',$result['g_id']);
			 	   $this->success("登陆成功","Index/main");
			 	}
			 	else 
			 	{
			 	  $this->error("密码错误！");
			 	}		  
			 }
			 else
			 {
			    $this->success("对不起,该用户不存在");
			 }
			 
		}
		else 
		{
		   return $this->fetch();
		}
	}
	public function quit()
	{
	  Session::delete('a_name');
	  $this->redirect('Login/login');
	}
	
}